package com.example.concurrent.singleton3;

public final class Singleton {
	private Singleton() {}
	private static volatile Singleton INSTANCE = null;
	//保证线程安全
	//锁的范围大，性能低
	public static  Singleton getInstance() {
		if(INSTANCE != null) {
			return INSTANCE;
		}
		synchronized(Singleton.class) {
			if(INSTANCE != null) {
				return INSTANCE;
			}	
			INSTANCE = new Singleton();
			return INSTANCE;
		}
	}
}
